package com.indra.archetypeweb.entity.book;

import java.sql.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import com.indra.archetypeweb.entity.base.BaseEntity;
import com.indra.archetypeweb.entity.product.Product;
import com.indra.archetypeweb.entity.user.User;

@Entity
@Table(name = "book")
@NamedQueries(value = {
		@NamedQuery(name = Book.FIND_BY_CATEGORY, query = "select b from Book b where b.idCategory = :idCategory"),
		@NamedQuery(name = Book.FIND_ALL, query = "select b from Book b")})

public class Book extends BaseEntity {
	
	public static final String FIND_ALL = "Book.findAll";
	public static final String FIND_BY_CATEGORY = "Book.findByCategory";
	
	@Id
	@GeneratedValue
	private Long id;

	@NotNull
	private Long idProduct;
	
	@NotNull
	@Size(min = 1, max = 25)
	@Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")
	private String writer;
	
	@NotNull
	@Size(min = 1, max = 25)
	@Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")
	private String publishingHouse;
	
	@NotNull
	@Size(min = 1, max = 25)	
	private String npages;
	
	@NotNull
	private Long idCategory;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getIdProduct() {
		return idProduct;
	}

	public void setIdProduct(Long idProduct) {
		this.idProduct = idProduct;
	}

	public String getWriter() {
		return writer;
	}

	public void setWriter(String writer) {
		this.writer = writer;
	}

	public String getPublishingHouse() {
		return publishingHouse;
	}

	public void setPublishingHouse(String publishingHouse) {
		this.publishingHouse = publishingHouse;
	}

	public String getNpages() {
		return npages;
	}

	public void setNpages(String npages) {
		this.npages = npages;
	}

	public Long getIdCategory() {
		return idCategory;
	}

	public void setIdCategory(Long idCategory) {
		this.idCategory = idCategory;
	}
	
	

}
